package com.jrtc.base.config.dto;


import com.jrtc.base.config.constants.ResponseMsg;


public  class  ResultDTOBuilder {

    public ResultDTOBuilder() {}

    public static  ResultDTO success() {
        return new ResultDTO(true,"00000" , ResponseMsg.msg.get("00000"),new Object());
    }

    public static  ResultDTO noPermission(Object data) {
        return new ResultDTO(true,"00403" , "没有权限",data);
    }

    public static ResultDTO success(String msg){
        return new ResultDTO(true,"00000" , msg,null);
    }

    public static  ResultDTO success(Object data) {
        return new ResultDTO(true,"00000" ,ResponseMsg.msg.get("00000"),data);
    }

    public static  ResultDTO failure(String code) {
        return new ResultDTO(false,code ,ResponseMsg.msg.get(code),new Object());
    }

    public static  ResultDTO failureMsg(String msg) {
        return new ResultDTO(false,"00003" ,msg,null);
    }

    public static  ResultDTO failure(String code,String msg) {
        return new ResultDTO(false,code ,msg,new Object());
    }

    public static  ResultDTO failure(String code,String msg,Object data) {
        return new ResultDTO(false,code ,msg,data);
    }

    public static  ResultDTO success(boolean b) {
        return b?success():failure("00004");
    }

    public static  ResultDTO success(int row) {
        return row > 0?success():failure("00004");
    }

    public static ResultDTO duplicateCheck(int num,String name){
        if(num>0){
            return new ResultDTO(false,"提示" , "所输入"+name+"重复，请重新输入！",name);
        }else{
            return new ResultDTO(true,"00000" , "所输入内容未重复",name);
        }
    }
}